package com.hoshiicloud.user.param.rbac;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hoshiicloud.common.query.PageParam;
import com.hoshiicloud.rbac.entity.SysRoles;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * <p>
 * 查询角色参数
 * </p>
 * 
 * @author Mr.Wu
 * @since 2019-04-27
 */
@Data
public class SysRolesQueryParam extends PageParam implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@ApiModelProperty(value = "id")
	private Long id;

	/**
	 * 角色分类(1-saas角色 2-租合角色 3-平台角色 4-其他
	 */
	@ApiModelProperty(value = "角色分类(1-saas角色 2-租合角色 3-平台角色 4-其他")
	private Integer type;

	/**
	 * 关联id 按角色分类
	 */
	@ApiModelProperty(value = "关联id  按角色分类")
	private Long relateId;

	/**
	 * 角色名称
	 */
	@ApiModelProperty(value = "角色名称")
	private String name;

	/**
	 * 角色标题
	 */
	@ApiModelProperty(value = "角色标题")
	private String title;

	/**
	 * 角色描述
	 */
	@ApiModelProperty(value = "角色描述")
	private String description;

	/**
	 * 排序
	 */
	@ApiModelProperty(value = "排序")
	private Long orders;

	public QueryWrapper<SysRoles> convertToQueryWrapper() {
		QueryWrapper<SysRoles> queryWrapper = new QueryWrapper<SysRoles>();
		queryWrapper.eq(this.id != null, "id", this.id);
		queryWrapper.eq(this.type != null, "type", this.type);
		queryWrapper.eq(this.relateId != null, "relate_id", this.relateId);
		queryWrapper.eq(StringUtils.isNotBlank(this.name), "name", this.name);
		queryWrapper.eq(StringUtils.isNotBlank(this.title), "title", this.title);
		queryWrapper.eq(StringUtils.isNotBlank(this.description), "description", this.description);
		queryWrapper.eq(this.orders != null, "orders", this.orders);
		return queryWrapper;
	}
}
